package com.liush.system.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.liush.common.result.Result;
import com.liush.model.controller.SysOperLog;
import com.liush.model.vo.SysOperLogQueryVo;
import com.liush.system.service.SysOperLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 操作日志记录 前端控制器
 * </p>
 *
 * @author liush
 * @since 2023-02-25
 */
@Api(tags = "操作日志控制器")
@RestController
@RequestMapping("/admin/system/sysOperLog")
public class SysOperLogController {

    @Autowired
    private SysOperLogService sysOperLogService;

    @ApiOperation("分页查询")
    @GetMapping("/{pageNum}/{pageSize}")
    public Result index(
            @ApiParam(value = "pageNum", name = "当前页数") @PathVariable Long pageNum,
            @ApiParam(value = "pageSize", name = "每页行数") @PathVariable Long pageSize,
            @ApiParam(value = "sysOperLogQueryVo", name = "查询对象") SysOperLogQueryVo sysOperLogQueryVo
    ) {
        Page<SysOperLog> page = new Page(pageNum, pageSize);
        Page<SysOperLog> sysOperLogPage = sysOperLogService.findPage(page, sysOperLogQueryVo);
        return Result.ok(sysOperLogPage);
    }

    @ApiOperation("操作日志的详情信息")
    @RequestMapping("/getById/{id}")
    public Result getById(@ApiParam(value = "id", name = "操作日志id") @PathVariable Long id) {
        SysOperLog sysOperLog = sysOperLogService.getById(id);
        return Result.ok(sysOperLog);
    }
}
